package com.zj.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seventh.common.pojo.R;
import com.zj.system.mapper.LogMapper;
import com.zj.system.pojo.entity.SysMenu;
import com.zj.system.pojo.entity.SysOperLog;
import com.zj.system.pojo.vo.LogVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: clms-seventh
 * @description: 日志记录的业务逻辑层
 * @author: 张静
 * @create: 2021-07-24 10:34
 **/
@Service
public class LogServiceImpl implements LogService{
    @Resource
    private LogMapper logMapper;
    @Override
    public R sel(Integer pageSize, Integer currentPage, LogVo vo) {
        Page<SysOperLog> page=new Page<>(currentPage,pageSize);
        QueryWrapper<SysOperLog> wrapper=new QueryWrapper<>();
        if (StringUtils.isNotEmpty(vo.getTitle())){
            wrapper.like("title",vo.getTitle());
        }
        if(StringUtils.isNotEmpty(vo.getStartDate())){
            wrapper.ge("oper_time",vo.getStartDate());
        }
        if(StringUtils.isNotEmpty(vo.getEndDate())){
            wrapper.le("oper_time",vo.getEndDate());
        }
        logMapper.selectPage(page,wrapper);
        return R.ok().put("tableData",page);
    }

    @Override
    public R del(Integer operId) {
        logMapper.deleteById(operId);
        return R.ok().put("message","删除成功");
    }
}
